﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace array
{
    internal class Program
    {
        static void Main(string[] args)
        {//先读入一串数字并把他们保存在数组当中
            Console.WriteLine("请输入一组数据：");
            string input = Console.ReadLine();
            string[] stringArray = input.Split(new[]{' '},StringSplitOptions.RemoveEmptyEntries);

            List<int> numberList = new List<int>();
            foreach (string str in stringArray)
            {if (int.TryParse(str, out int number))
                {
                    numberList.Add(number);
                }
                else
                {
                    Console.WriteLine($"无法将字符{str}转换成整数，请保证输入正确！");
                }
            }
            if (numberList.Count == 0)
            {
                Console.WriteLine("没有有效的整数输入！");
            }

            int max= numberList[0];
            int min= numberList[0];
            double sum = 0;

            foreach (int num in numberList)
            { if (num > max)
                { max = num; }
              if (num < min)
                { min = num; }
                sum += num;
            }
            double aver = sum / numberList.Count;
            Console.WriteLine($"这组数的最大值是：'{max}’");
            Console.WriteLine($"这组数的最小值是：'{min}’");
            Console.WriteLine($"这组数的总和是：'{sum}’");
            Console.WriteLine($"这组数的平均值是：'{aver}’");

            Console.ReadLine();











        }
    }
}
